﻿
@{
    ViewData["Title"] = "用户表单";
    Layout = "~/Views/Shared/_LayoutForm.cshtml";
}
@section styles{
    <style type="text/css">
        .col-sm-3 {
            width: 25% !important;
            float: left;
            padding-top: 7px;
            margin-bottom: 0;
            text-align: right;
        }

        .col-sm-9 {
            width: 73% !important;
            float: left;
        }

        .ibox-content {
            padding-bottom: 15px !important;
        }
    </style>
}
<div class="row">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-content">
                <form class="form-horizontal">
                    <input type="hidden" id="id" name="id" />
                    <div class="form-group">
                        <label class="col-sm-3 control-label">登录名</label>
                        <div class="col-sm-9">
                            <input type="text" id="loginName" name="loginName" placeholder="请输入登录名" class="form-control" isvalid="yes" checkexpession="NotNull" autocomplete="off">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">真实姓名：</label>
                        <div class="col-sm-9">
                            <input type="text" id="realName" name="realName" placeholder="请输入真实姓名" class="form-control" autocomplete="off">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">原密码：<font face="宋体">*</font></label>
                        <div class="col-sm-9">
                            <input type="password" id="oldPwd" name="oldPwd" placeholder="请输入密码" class="form-control" isvalid="yes" checkexpession="NotNull" autocomplete="off">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">密码：<font face="宋体">*</font></label>
                        <div class="col-sm-9">
                            <input type="password" id="pwd" name="pwd" placeholder="请输入密码" class="form-control" isvalid="yes" checkexpession="NotNull" autocomplete="off">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">确认密码：<font face="宋体">*</font></label>
                        <div class="col-sm-9">
                            <input type="password" id="confirmPwd" name="confirmPwd" placeholder="请输入密码" class="form-control" isvalid="yes" checkexpession="NotNull" autocomplete="off">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

@section scripts{
<script type="text/javascript">
        var userForm = function () {
            var _self = this;
            _self.id = '@ViewBag.id';
            _self.InitData = function() {
                if (_self.id) {
                    $.SetForm({
                        url: "Get",
                        param: { id: _self.id },
                        success: function(data) {
                            $("form").SetWebControls(data);
                            $("#loginName").attr("disabled", "disabled");
                            $("#realName").attr("disabled", "disabled");
                        }
                    });
                }
            };

            return {
                init: function () {
                    _self.InitData();
                },
                acceptClick: function (index) {
                    if (!$("form").Validform()) {
                        return false;
                    }
                    var data = $("form").GetWebControls();
                    $.ajax({
                        url: "ChangePwdForm",
                        data: data,
                        type: "post",
                        dataType: "json",
                        async: false,
                        success: function (result) {
                            //Loading(false);
                            if (result.state == "1") {
                                top.layer.close(index);
                                top.location.href = "/home/Logout";
                            } else {
                                top.layer.alert(result.message, {
                                    icon: -1,
                                    title: "提示",
                                    move: false
                                });
                               
                            }
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            //Loading(false);
                            alert(errorThrown);
                        }
                    });
                }
            }
        }();
        userForm.init();
</script>
}

